home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
boe.pres.k12.wv.us
/
boe.pres.k12.wv.us.zip
/
boe.pres.k12.wv.us
/
Utilities
/
Xerox Workcentre 5335
/
Windows Scan
/
64-bit_x64
/
Russian
/
cpsimage.cab
/
data
/
xipScripts
/
matchLift.elf
< prev
next >
Wrap
Text File
|
2009-04-23
|
5KB
|
169 lines
/*
** Copyright(c) 2006 Xerox Corp. All Rights Reserved. Copyright protection
** claimed includes all forms and mattersof copyrightable material and
** information now allowed by statutory or judicial law or hereinafter granted,
** including without limitation, material generated from the software programs
** which are displayed on the screen such as icons, screen display looks, etc.
*/
#load "sys/stdlib.elf";
#import "documentio.ucm";
#import "ipcore2xip.ucm";
#functions "ml2xip.ucm";
STRING USAGE = "\
Given two input document images (an original and an annotated copy), this\
script extracts the annotations present in the copy; repairs any broken\
strokes in the annotations; and outputs the difference image containing only\
the reconstructed annotations. The default output format is PDF.\
Usage and import options are listed below:\n\n\
Usage: xipe mathcLift\
-im origfile:s orignal filename // required\
copyfile:s annotated copy filename // required\
outfile:s outfilename // def: <copyfile>.ml.pdf\
format:s output format // def: pdf\
save:i save to disk // def: 1 (true)\
display:i display output // def: 0 (false)\
debug:i emit intermediate images // def: 0 (false)\n";
IMPORT STRING copyfile;
IMPORT STRING origfile;
IMPORT STRING outfile;
IMPORT STRING format = "pdf";
IMPORT INTEGER save = 1;
IMPORT INTEGER display = 0;
IMPORT INTEGER debug = 0;
XIPIMAGE imgOrig, imgCopy, imgDiff;
FILE file;
// Load image processing functions
LoadClasses (filename: "xeng");
// Check for original filename
if (!origfile) {
print "No original document filename specified";
print USAGE;
end;
}
// Check if original file exists
file = new (FILE, path: origfile);
if (!file.exists ()) {
print "Original document file does not exist";
print USAGE;
end;
}
// Check if original filename specifies a file
if (!file.isFile ()) {
print "Original document file is a directory";
print USAGE;
end;
}
// Check for annotated copy filename
if (!copyfile) {
print "No annotated copy document filename specified";
print USAGE;
end;
}
// Check if annotated copy file exists
file = new (FILE, path: copyfile);
if (!file.exists ()) {
print "Annotated copy document file does not exist";
print USAGE;
end;
}
// Check if annotated copy filename specifies a file
if (!file.isFile ()) {
print "Annotated copy document file is a directory";
print USAGE;
end;
}
// Read original document image
imgOrig = readimage (filename: origfile).exec ();
// Read copy image
imgCopy = readimage (filename: copyfile).exec ();
// Adjust dimension of document images accordingly
// Note: This is a temporary fix for making certain the document images can be
// aligned in the document matching phase. A better solution needs to be
// implemented (most likely embedded in the MatchLift function) for handling
// the alignment issue.
DOUBLE w_orig = imgOrig.imageWidth;
DOUBLE h_orig = imgOrig.imageHeight;
DOUBLE w_copy = imgCopy.imageWidth;
DOUBLE h_copy = imgCopy.imageHeight;
DOUBLE sx_orig = 1.0;
DOUBLE sy_orig = 1.0;
DOUBLE sx_copy = 1.0;
DOUBLE sy_copy = 1.0;
INTEGER r;
if (w_copy > w_orig) {
r = w_copy / w_orig;
if (r > 1)
sx_copy = w_orig / w_copy;
}
else {
r = w_orig / w_copy;
if (r > 1)
sx_orig = w_copy / w_orig;
}
if (h_copy > h_orig) {
r = h_copy / h_orig;
if (r > 1)
sy_copy = h_orig / h_copy;
}
else {
r = h_orig / h_copy;
if (r > 1)
sy_orig = h_copy / h_orig;
}
if (sx_orig != 1.0 || sy_orig != 1.0)
imgOrig = imgOrig.scale (afactor: (sx_orig, sy_orig), bicubic: 1);
if (sx_copy != 1.0 || sy_copy != 1.0)
imgCopy = imgCopy.scale (afactor: (sx_copy, sy_copy), bicubic: 1);
// Make certain original image is 1-bit gray
if (imgOrig.getMember (member: "photometry") != XIP_GRAY_COLOR)
imgOrig = imgOrig.cspace (outspace: "gray");
if (imgOrig.getMember (member: "bits") != 1)
imgOrig = imgOrig.convert (to: (1));
// Make certain copy image is 8-bit gray
if (imgCopy.getMember (member: "photometry") != XIP_GRAY_COLOR)
imgCopy = imgCopy.cspace (outspace: "gray");
if (imgCopy.getMember (member: "bits") != 8)
imgCopy = imgCopy.convert (to: (8));
// Get difference image of original and copy images
imgDiff = MatchLift (orig: imgOrig, copy: imgCopy, debug: debug);
print "Total Excution Time For Script: " + TimeCheck ();
// Display difference image if display is TRUE
if (display)
imgDiff.display (advanced: "spd -buffer");
// Save difference image if save is TRUE
if (save) {
DOCUMENTWRITER dw;
if (!outfile)
outfile = copyfile.name () + "-annlift." + format;
dw = CreateDocumentWriter (filename: outfile);
dw.appendPage (pgImg: imgDiff);
dw.release ();
}